home *** CD-ROM | disk | FTP | other *** search
/ Champak 138 / Volume 138 Aug 19 2011 - Damaged.iso / Games / the_independent.swf / scripts / frame_5 / DoAction_4.as < prev    next >
Text File  |  2011-08-19  |  9KB  |  361 lines

  1. function float()
  2. {
  3.    if(hitEnd == 1)
  4.    {
  5.       this.xAcc *= -1;
  6.       this._xscale *= -1;
  7.    }
  8.    this._x += this.xAcc - WXacc;
  9.    this._y += mRd(2 * math.sin(this.yAcc) - WYacc);
  10.    this.relX += this.xAcc;
  11.    this.yAcc += 0.05;
  12.    if(this.relX > 1750)
  13.    {
  14.       this.relX = 1750;
  15.       this.xAcc *= -1;
  16.       this._xscale *= -1;
  17.    }
  18.    else if(this.relX < 0)
  19.    {
  20.       this.relX = 0;
  21.       this.xAcc *= -1;
  22.       this._xscale *= -1;
  23.    }
  24.    if(paper != undefined)
  25.    {
  26.       if(this.hittest(paper._x,paper._y,false))
  27.       {
  28.          if(this["class"] == "pigeon" && pigeonHit != this.num)
  29.          {
  30.             _global.score += 25;
  31.             pigeonHit = this.num;
  32.             this.gotoandplay("hit");
  33.             updatescore();
  34.             this.xAcc *= -1;
  35.             this._xscale *= -1;
  36.             playFX("hitPigeon");
  37.          }
  38.       }
  39.    }
  40. }
  41. function control()
  42. {
  43.    WXacc = mRd(mMx(mMn((this.targ._x - 250) / 10,20),-20));
  44.    if(this._y < 400)
  45.    {
  46.       WYacc = mRd(mMx(mMn((this.targ._y - 200) / 10,20),-20));
  47.    }
  48.    else if(this._y > 400)
  49.    {
  50.       WYacc = 400 - this._y;
  51.    }
  52.    if(this._y == 400)
  53.    {
  54.       if(mRd(mMx(mMn((this.targ._y - 200) / 10,20),-20)) < 0)
  55.       {
  56.          WYacc = mRd(mMx(mMn((this.targ._y - 200) / 10,20),-20));
  57.       }
  58.       else
  59.       {
  60.          WYacc = 0;
  61.       }
  62.    }
  63.    this._x += WXacc;
  64.    this._y += WYacc;
  65.    ground._y -= WYacc;
  66.    bkgrnd._y = ground._y / 2 - 475;
  67.    if(WXacc == 0)
  68.    {
  69.       if(_global.section == 2)
  70.       {
  71.          _root.sectionStart(3);
  72.       }
  73.       else if(_global.section == 5)
  74.       {
  75.          _root.sectionStart(6);
  76.       }
  77.    }
  78.    if(WXacc > 0)
  79.    {
  80.       curOb = oForeBuild;
  81.       if(this._x + 400 > curOb.aPos[curOb.nextBuild])
  82.       {
  83.          if(curOb.aPos[curOb.nextBuild] != undefined)
  84.          {
  85.             addNextBuilding(curOb,this._x + 400 - curOb.aPos[curOb.nextBuild]);
  86.          }
  87.       }
  88.       curOb = oBackBuild;
  89.       if(this._x + 400 > curOb.aPos[curOb.nextBuild])
  90.       {
  91.          if(curOb.aPos[curOb.nextBuild] != undefined)
  92.          {
  93.             addNextBuilding(curOb,this._x + 400 - curOb.aPos[curOb.nextBuild]);
  94.          }
  95.       }
  96.    }
  97.    else
  98.    {
  99.       curOb = oForeBuild;
  100.       if(this._x - 400 < curOb.aPos[curOb.prevBuild])
  101.       {
  102.          if(curOb.aPos[curOb.prevBuild] != undefined)
  103.          {
  104.             addPrevBuilding(curOb,this._x - 400 - curOb.aPos[curOb.prevBuild]);
  105.          }
  106.       }
  107.       curOb = oBackBuild;
  108.       if(this._x - 400 < curOb.aPos[curOb.prevBuild])
  109.       {
  110.          if(curOb.aPos[curOb.prevBuild] != undefined)
  111.          {
  112.             addPrevBuilding(curOb,this._x - 400 - curOb.aPos[curOb.prevBuild]);
  113.          }
  114.       }
  115.    }
  116. }
  117. function move()
  118. {
  119.    this._x -= WXacc * this["class"].para;
  120.    this._y -= WYacc;
  121.    this["class"].curY = this._y;
  122.    if(this._x < -150)
  123.    {
  124.       this["class"].prevBuild = this.num;
  125.       this["class"].aPos[this.num] = controller._x - 400;
  126.       this.removeMovieClip();
  127.    }
  128.    if(this._x > 650)
  129.    {
  130.       this["class"].nextBuild = this.num;
  131.       this["class"].aPos[this.num] = controller._x + 400;
  132.       this.removeMovieClip();
  133.    }
  134. }
  135. function movePeople()
  136. {
  137.    this._x -= WXacc;
  138.    this._y -= WYacc;
  139.    if(this.hittest(paper._x,paper._y,false))
  140.    {
  141.       checkHit(this);
  142.    }
  143. }
  144. function search()
  145. {
  146.    this._x -= WXacc;
  147.    this._y -= WYacc;
  148. }
  149. function checkHit(ob)
  150. {
  151.    if(ob["class"] == oPeople && ob.person._currentframe == 1)
  152.    {
  153.       ob.person.play();
  154.       peopleHit();
  155.       controller.targ = ob;
  156.       paper.removeMovieClip();
  157.    }
  158.    else if(ob["class"] == oObstacles && _global.lastOb != ob.num && _global.breakout < 30)
  159.    {
  160.       _global.breakout = _global.breakout + 1;
  161.       _global.lastOb = ob.num;
  162.       if(paper.relY > 290)
  163.       {
  164.          _global.potScore -= mRd(mAb(paper.Xacc));
  165.          paper.Xacc *= -0.8;
  166.          paper.rot *= -0.8;
  167.          playFX("hitTree");
  168.       }
  169.       else
  170.       {
  171.          if(paper.Yacc > 0)
  172.          {
  173.             _global.potScore -= mRd(mAb(paper.Yacc));
  174.             paper.Yacc *= -0.5;
  175.             paper.rot *= 0.8;
  176.          }
  177.          else
  178.          {
  179.             _global.potScore -= mRd(mAb(paper.Xacc));
  180.             paper.Yacc = - mAb(paper.Xacc * 0.5);
  181.             paper.Xacc = mAb(paper.Yacc * 0.5);
  182.             paper.rot *= 0.8;
  183.          }
  184.          playFX("hitLamp");
  185.       }
  186.    }
  187.    else if(ob["class"] == oBaddy)
  188.    {
  189.       ob.play();
  190.       baddyHit();
  191.       controller.targ = ob;
  192.       paper.removeMovieClip();
  193.    }
  194. }
  195. function baddyHit()
  196. {
  197.    _global.peopleScore = _global.peopleScore + 1;
  198.    scoreBar["icon" + _global.peopleScore].gotoandstop(3);
  199.    _global.score -= 50;
  200.    updateScore();
  201.    playFX("hitBad");
  202. }
  203. function peopleHit()
  204. {
  205.    _global.peopleHit = _global.peopleHit + 1;
  206.    _global.peopleScore = _global.peopleScore + 1;
  207.    scoreBar["icon" + _global.peopleScore].gotoandstop(2);
  208.    _global.score += _global.potScore;
  209.    updateScore();
  210.    playFX("hitGood");
  211. }
  212. function updateScore()
  213. {
  214.    scoreBar.score.text = _global.score;
  215. }
  216. function moveTrail()
  217. {
  218.    this._x -= WXacc;
  219.    this._y -= WYacc;
  220.    this._alpha -= 2;
  221.    if(this._alpha <= 0)
  222.    {
  223.       this.removeMovieClip();
  224.    }
  225. }
  226. function moveArrow()
  227. {
  228.    this._x -= WXacc;
  229.    this._y -= WYacc;
  230.    if(!Key.isDown(17))
  231.    {
  232.       this._visible = true;
  233.       viewingArrows._visible = false;
  234.       searcher._x = paperBoy._x;
  235.       searcher._y = paperBoy._y;
  236.       if(Key.isDown(39))
  237.       {
  238.          this.rot = this.rot + 1;
  239.       }
  240.       else if(Key.isDown(37))
  241.       {
  242.          this.rot--;
  243.       }
  244.       if(Key.isDown(38))
  245.       {
  246.          this.acc = this.acc + 1;
  247.       }
  248.       else if(Key.isDown(40))
  249.       {
  250.          this.acc--;
  251.       }
  252.    }
  253.    else
  254.    {
  255.       this._visible = false;
  256.       viewingArrows._visible = true;
  257.       if(Key.isDown(39))
  258.       {
  259.          searcher._x += 20;
  260.       }
  261.       else if(Key.isDown(37))
  262.       {
  263.          searcher._x -= 20;
  264.       }
  265.    }
  266.    if(this.rot < 0.1 && this.rot > -0.1)
  267.    {
  268.       this.rot = 0;
  269.    }
  270.    if(this.arrow._rotation < -90)
  271.    {
  272.       this.rot *= -1;
  273.       this.arrow._rotation = -90;
  274.    }
  275.    else if(this.arrow._rotation > 0)
  276.    {
  277.       this.rot *= -1;
  278.       this.arrow._rotation = 0;
  279.    }
  280.    if(this.arrow.arrowBit._x < -15.5)
  281.    {
  282.       this.acc *= -0.5;
  283.       this.arrow.arrowBit._x = -15.5;
  284.    }
  285.    else if(this.arrow.arrowBit._x > 37.5)
  286.    {
  287.       this.acc *= -0.5;
  288.       this.arrow.arrowBit._x = 37.5;
  289.    }
  290.    this.rot *= 0.8;
  291.    this.acc *= 0.8;
  292.    this.arrow._rotation += this.rot;
  293.    this.arrow.arrowBit._x += this.acc;
  294.    this.arrow.arrowBit2._x = this.arrow.arrowBit._x;
  295.    if(Key.isDown(32))
  296.    {
  297.       sectionStart(4);
  298.       playFX("throw");
  299.    }
  300. }
  301. function movePaper()
  302. {
  303.    this._x += this.Xacc - WXacc;
  304.    this._y += this.Yacc - WYacc;
  305.    this._rotation += this.rot;
  306.    this.rot *= 0.99;
  307.    this.relY += this.Yacc;
  308.    this.Xacc *= 0.993;
  309.    this.Yacc += 0.29;
  310.    if(this.relY > 360)
  311.    {
  312.       this.Yacc *= -0.5;
  313.       this.Xacc *= 0.8;
  314.       this.rot *= 0.8;
  315.       this._y -= this.rely - 360;
  316.       this.relY = 360;
  317.       this.bounce = this.bounce + 1;
  318.       _global.potScore -= mRd(mAb(this.Yacc));
  319.       playFX("hitGround");
  320.    }
  321.    if(mAb(this.Xacc) < 4 && this.bounce > 4)
  322.    {
  323.       _global.peopleScore = _global.peopleScore + 1;
  324.       scoreBar["icon" + _global.peopleScore].gotoandstop(3);
  325.       _root.sectionStart(5);
  326.       this.removeMovieClip();
  327.    }
  328.    var t = _root.attachMovie("paper","trail" + this.tNum,4700 + this.tNum);
  329.    t._x = this._x;
  330.    t._y = this._y;
  331.    t._rotation = this._rotation;
  332.    t._alpha = 20;
  333.    t.onenterframe = moveTrail;
  334.    if(++this.tNum > 20)
  335.    {
  336.       this.tNum = 0;
  337.    }
  338. }
  339. function addNextBuilding(oName, offset)
  340. {
  341.    var s = _root.attachMovie(oName.title,oName.title + oName.nextBuild,oName.lev + oName.nextBuild);
  342.    s._y = s.relY = oName.curY;
  343.    s._x = 650 - offset;
  344.    s.num = oName.nextBuild;
  345.    s["class"] = oName;
  346.    s.gotoandstop(oName.aType[oName.nextBuild]);
  347.    oName.nextBuild = oName.nextBuild + 1;
  348.    s.onenterframe = move;
  349. }
  350. function addPrevBuilding(oName, offset)
  351. {
  352.    var s = _root.attachMovie(oName.title,oName.title + oName.prevBuild,oName.lev + oName.prevBuild);
  353.    s._y = oName.curY;
  354.    s._x = -150 - offset;
  355.    s.num = oName.prevBuild;
  356.    s["class"] = oName;
  357.    s.gotoandstop(oName.aType[oName.prevBuild]);
  358.    oName.prevBuild--;
  359.    s.onenterframe = move;
  360. }
  361.